﻿using System;
using System.Web.Mvc;
using System.Web.Http.Controllers;

namespace Flagwind.Web.Plugins
{
	public class PluginHttpControllerActionSelector : System.Web.Http.Controllers.ApiControllerActionSelector
	{
		public override HttpActionDescriptor SelectAction(HttpControllerContext controllerContext)
		{
			var action = controllerContext.RouteData.Values["action"];

			if(action == null || action == UrlParameter.Optional)
				controllerContext.RouteData.Values["action"] = controllerContext.Request.Method.Method;

			//调用基类同名方法
			return base.SelectAction(controllerContext);
		}
	}
}
